
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cglist.css"/>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/add.css"/>

    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/cg_info.css"/>
    <script type="text/javascript" src="/plan/caigou/js/jquery.1.9.1.js" ></script>
    <script type="text/javascript" src="/plan/caigou/js/layer.js" ></script>
    <link rel="stylesheet" type="text/css" href="/plan/caigou/css/layer.css"/>

    <script type="text/javascript" src="/plan/caigou/js/rem.js" ></script>
    <title>采购订单详情</title>
</head>
<style>
    #add1{display: block}
    #add3{display: none}
    .cglist li p.cginfo{
        height: .38rem;
        padding-top: .2rem;
    }
</style>
<section id="add1">
<div>
    <ul class="cglist">
        <li>

                <p class="number">
                    <span class="num_left">{$info['supplier']}</span>
                   {$info['status_text']}
                </p>
                <p class="cginfo">
                    <span>单据编号</span>{$info['order_id']}
                </p>
                <p class="cginfo">
                    <span>单据状态</span>{if condition="$info['status'] eq 2"}部分入库{else}未入库{/if}
                </p>
                <p class="cginfo">
                    <span>采购人员</span>{$info['username']}
                </p>
                <p class="cginfo">
                    <span style="float: left;">单据备注</span>
                    <span style="width: 77%;display: inline-block;color: #333;">{$info['mark']}</span>
                </p>

        </li>
    </ul>
    <div class="jiesuan">
        <p class="title">结算明细</p>

        <p class="info">总数量<span>{$info['total']} ( {$info['count']}种 )</span></p>
        <p class="info">采购金额合计<span>¥{:number_format($info['total_money'],2,".",",")}</span></p>
        <p class="info">其他金额<span>+  ¥{:number_format($info['other_money'],2,".",",")}</span></p>
        <p class="bottom">应付款：<span>¥{:number_format($info['total_money'],2,".",",")}</span></p>
    </div>
    <ul class="productinfo" id="pro3">
        <p style="color: #666;">产品</p>
        {volist name="list" id="vo"}
            <li dataid="{$vo['shopid']}">
                <div class="infoleft"><img src="/plan/caigou/img/product.png"/></div>
                <div class="inforight">
                    <p>{$vo.cname}</p>
                    <p class="infop2">仓库：北京仓库</p>
                    <p class="infop3">¥{$vo.price}×<span id="znum{$vo['shopid']}">{$vo.num}</span>本{if condition="$info['status'] < 4"}   待入库数量{$vo['num']-$vo['actual']}{/if}</p>
                </div>
            </li>
        {/volist}

    </ul>
    {notempty name="worklist"}

    <ul class="list_info">
        <p class="title">审批流程</p>
        {volist name="worklist" id="vo"}

        <li>
            {if condition="$vo['status'] eq 2"}
            <img class="tx" src="/plan/caigou/img/bohui.jpg"/>
            {else}
            <img class="tx" src="/plan/caigou/img/ing.jpg"/>
            {/if}
            <p class="question">

                <img src="{$vo['user']['avatar']}"/>

                <span>{$vo['user']['username']} ·             {if condition="$vo['status'] eq 1"}
已通过 {elseif condition="$vo['status'] eq 2"}已驳回{else}审批中{/if}</span>
            </p>

            <p class="infodate">
                {$vo.mark}
            </p>

        </li>

        {/volist}
    </ul>
    {/notempty}
        <div class="sug"  {in name="info['status']" value="9,8,7,6"}style="margin-top:0.2rem"{else}style="margin-top:0"{/in}>
            {in name="info['status']" value="9,8,7,6"}
                    {in name="userid" value="$userArr"}

                        <p class="titie">审批意见</p>
                        <textarea style="height: 2rem;" id="mark"></textarea>
                {/in}

              {/in}
        </div>


    {if condition="$info['status'] eq 10 "}
    {in name="userid" value="$userArr"}

            <div class="cgbutton">
                   <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
                   <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="提交审核"/></div>
                </div>
    {/in}
    {elseif  condition="$info['status'] eq 9"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
        <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 8"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
         <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 7"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>驳回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="通过"/></div>
</div>
    {/in}


    {elseif  condition="$info['status'] eq 5"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>编辑</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="作废"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 4"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>返回</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="添加"/></div>
    </div>
    {/in}
{elseif  condition="$info['status'] eq 3"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
    <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>采购入库</div></a>
<div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="作废"/></div>
</div>
    {/in}
    {elseif  condition="$info['status'] eq 2"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>采购入库</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="完成"/></div>
    </div>
    {/in}
    {elseif  condition="$info['status'] eq 1"}
    {in name="userid" value="$userArr"}

    <div class="cgbutton">
        <div class="cgclose" id="zbianji" data-info='{"id":{$info["id"]},"status":{$info['status']}}'>已完成</div></a>
    <div class="cgcontinue"  id="tijiao" data-info='{"id":{$info["id"]},"status":{$info['status']}}'><input class="cgpay" type="button" value="添加采购单"/></div>
    </div>
    {/in}
    {/if}


</section>
{in name="info['status']" value="3,2"}

<section id="add3">
        <ul class="productinfo">
            <li>
                <div class="infoleft"><img src="/plan/caigou/img/product.png"/></div>
                <div class="inforight">
                    <p id="title3"></p>
                    <p class="infop3" id="store3">库存:</p>
                </div>
            </li>
        </ul>
        <ul class="order_money" style="padding: 0 0.3rem;background: #fff;">

            <li>
                <span class="address">下单数量</span>
                <input type="number" id="num3" onkeyup="this.value.replace(/\D/g,'')" disabled  placeholder="请输入数量"></input>
            </li>
            <li>
                <span class="num" style="text-align: left">入库数量</span>
                <span class="bitian">必填</span>
                <input type="number" id="week3"  onkeyup="this.value.replace(/\D/g,'')" placeholder="请输入数量" value=""></input>
            </li>

        </ul>
        <div class="button">
            <div class="close" id="del3" style="margin-left: 0">取消</div>
            <div class="continue" id="btn3">保存<!--<input class="pay" type="submit" name="" id="" value="保存" />--></div>
        </div>


</section>
{/in}
</body>
<script>
    var shopList={$jsList};
    var tempId;

    $(function () {
        {in name="info['status']" value="3,2"}
            $("#pro3 li").click(function () {
                var _this = $(this);
                let did = _this.attr('dataid');
                $("#title3").html(shopList["flg_"+did].cname);
                $("#store3").html("库存："+shopList["flg_"+did].storenum);
                $("#num3").val(shopList["flg_"+did].num);
                $("#week3").val(shopList["flg_"+did].num-shopList["flg_"+did].actual);
                $("#add1").hide();
                $("#add3").show();
                tempId=did;
            });
            $("#del3").click(function () {
                $("#add3").hide();
                $("#add1").show();
            });
            $("#btn3").click(function () {
                if ( $("#week3").val() < 1){
                    layer.open({
                        content:'入库数量必填' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    return false;
                }
                shopList["flg_"+tempId].total=$("#week3").val();


                $("#znum"+tempId).html($("#week3").val());

                $("#add3").hide();
                $("#add1").show();
            });
        {/in}
    $("#zbianji").click(function () {
        let data = JSON.parse($(this).attr("data-info"));
        switch (data.status){
            case 10:
                location.href="/index/store/edit/id/"+data.id;
                break;
            case 9:
                examine(9);
                break;
            case 8:
                examine(8);
            case 7:
                examine(7);
                break;
            case 6:
                examine(6);
                break;
            case 3:
                setstore();
                break;
            case 2:
                setstore();
                break;
            case 5:
                location.href="/index/store/edit/id/"+data.id;
                break;
            case 4:
                location.href="/index/store/lists/";
                break;

        }
    });
    $("#tijiao").click(function () {

        let data = JSON.parse($(this).attr("data-info"));
        switch (data.status){
            case 10:
               //提交审核
                oper(10);
                break;
            case 9:

                oper(9);
                break;
            case 8:
                oper(8);
                break;
            case 7:
                oper(7);
                break;
            case 6:
                oper(6);
                break;
            case 3:
                oper(5);
            case 2:
                oper(2);
            case 5:
                oper(5);
                break;
            case 4:
                location.href="/index/store/cgadd/";
                break;
            case 1:
                location.href="/index/store/cgadd/";
                break;
        }
    });
})
    function oper(status) {
        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        $(".cgclose,.cgcontinue").addClass("disabled");
        let mark = $("#mark").val();

        layer.open({type: 2,  shadeClose: false});
        $.ajax({
            type:"post",
            url:"/index/store/oper",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {

                layer.closeAll();

                if (data.code==1){

                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },800);
                } else{
                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/store/lists"
                    },800);
                }

            }

        })

    }
    function setstore() {
        for ( let i in shopList){
            delete shopList[i].cname;
            delete shopList[i].price;
            delete shopList[i].storenum;
        }

        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        $(".cgclose,.cgcontinue").addClass("disabled");
        let mark = $("#mark").val();

        layer.open({type: 2, shadeClose: false});
        $.ajax({
            type: "post",
            url: "/index/store/housing",
            data: {id: {$info['id']}, shopList:shopList},
            success: function (data) {
                layer.closeAll();

                if (data.code==1){

                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },800);
                } else{
                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/store/lists"
                    },800);
                }

            }
        });
    }
    function examine(status) {
        if ($(".cgclose").hasClass("disabled") || $(".cgcontinue").hasClass("disabled")) return false;
        let mark = $("#mark").val();

        if (mark==''){
            layer.open({
                content:'请输入驳回意见' ,
                skin: 'msg',
                time: 2 //2秒后自动关闭
            });
            return false;
        }
        $(".cgclose,.cgcontinue").addClass("disabled");
        layer.open({type: 2,  shadeClose: false});

        $.ajax({
            type:"post",
            url:"/index/store/reject",
            data:{id:{$info['id']},status:status,mark:mark},
            success:function (data) {
                layer.closeAll();

                if (data.code==1){

                    layer.open({
                        content:'操作成功' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        location.reload();
                    },600);
                } else{
                    layer.open({
                        content:''+data.msg+'' ,
                        skin: 'msg',
                        time: 2 //2秒后自动关闭
                    });
                    setTimeout(function () {
                        window.location.href="/index/store/lists"
                    },200);
                }

            }

        })
    }
</script>
</html>
